package cool.taomu.toolkit.platform.controller

import java.util.Map
import javax.servlet.http.HttpServletRequest
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.Produces
import javax.ws.rs.core.Context
import javax.ws.rs.core.MediaType
import org.glassfish.jersey.server.mvc.ErrorTemplate
import org.glassfish.jersey.server.mvc.Template
import org.slf4j.LoggerFactory
import cool.taomu.toolkit.platform.entity.MenuEntity

@Path("index")
class IndexController extends BaseController {

	val static LOG = LoggerFactory.getLogger(IndexController);

	@GET
	@ErrorTemplate(name="/error.ftl")
	@Template(name="/main.ftl")
	@Produces(MediaType.TEXT_HTML)
	def Map<String, Object> index() {
		LOG.info("默认方法");
		return #{"pathSpec" -> pathSpec, "title" -> title, "navbar" -> "nav", "content" -> "content", "userid" -> "0",
			"menus" -> menuService.menuList,"name"->"主页"};
	}

	@GET
	@Path("{userid}")
	@ErrorTemplate(name="/error.ftl")
	@Template(name="/main.ftl")
	@Produces(MediaType.TEXT_HTML)
	def Map<String, Object> index(@PathParam("userid") String userid, @Context HttpServletRequest request) {
		LOG.info("用户id:{}", userid);
		return #{"pathSpec" -> pathSpec, "title" -> title, "navbar" -> "nav", "content" -> "content", "userid" -> "0",
			"menus" -> menuService.menuList,"name"->"主页"};
	}

}
